package com.hnevc.trafficdemotest1.fragment;


import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hnevc.trafficdemotest1.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class UserCenterFragment extends Fragment {
    Activity mActivity;
    Fragment mFragment1,mFragment2,mFragment3;
    TextView mTvUserInfo,mTvRechargeRecord,mTvBoundSet;
    public UserCenterFragment() {
        mFragment1 = new PersonMessageFragment();
        mFragment2 = new RechargeRecordFragment();
        mFragment3 = new BoundSetFragment();
    }



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_user_center, container,false);
        mTvUserInfo = (TextView) view.findViewById(R.id.id_tv_user_info);
        mTvRechargeRecord = (TextView) view.findViewById(R.id.id_tv_user_rechargere_corde);
        mTvBoundSet = (TextView) view.findViewById(R.id.id_tv_user_band_set);
        mTvUserInfo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getChildFragmentManager().beginTransaction()
                        .replace(R.id.id_fl_container,mFragment1)
                        .commit();
            }
        });
        mTvRechargeRecord.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getChildFragmentManager().beginTransaction()
                        .replace(R.id.id_fl_container,mFragment2)
                        .commit();
            }
        });
        mTvBoundSet.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getChildFragmentManager().beginTransaction()
                        .replace(R.id.id_fl_container,mFragment3)
                        .commit();
            }
        });
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mActivity = getActivity();
        getChildFragmentManager().beginTransaction()
                .replace(R.id.id_fl_container,mFragment1)
                .commit();

    }
}
